<template>
	<div class="demo">
		<h2 class="title">学生姓名：{{name}}</h2>
		<h2 class="atguigu">学生性别：{{sex}}</h2>
    <button @click="sendStudentName">把学生名给app</button>
    <button @click="unbind">解绑atguigu事件</button>
	</div>
</template>

<script>
	export default {
		name:'Student',
		data() {
			return {
				name:'张三',
				sex:'男'
			}
		},
    methods:{
      sendStudentName(){
        //触发student实例对象身上的@atguigu事件
        this.$emit('atguigu',this.name)
      },
      unbind(){
        //解绑多个事件
        // this.$off(['atguigu','xxx'])
        //解绑事件
        this.$off('atguigu')
      }
    }
	}
</script>

<style lang="less" scoped>
	.demo{
		background-color: pink;
		.atguigu{
			font-size: 40px;
		}
	}
</style>
